<?php
ArrowController::importModel("org.arrowplatform.controls.presentation.table.columns.ArrowAbstractTableColumn");
class ArrowTableAccessShareColumn extends ArrowAbstractTableColumn{
	private $width;
	private $simpleField;
	private $viewFormat;
	//private $mapping;
	
	public function configure(){
		parent::configure();
		$this->addProperties(array(
			"masterCtrlId" => null
		));
		
		
		$this->addRequiredProperties( array( "masterCtrlId" ) );
		$this->setContentCodeKept(true);
	}
	
	public function init(){
		parent::init();
		$this->registerJs( get_class($this), dirname(__FILE__)."/resources/".get_class($this).".js", ".".self::CTRL_NAMESPACE."-table-access-share", array( "masterCtrlId" => $this->getProperty('masterCtrlId') ) );
		
		$this->width = $this->getProperty("width");
		
		if(strpos($this->field, ";") !== false){
			$ex = explode(";", $this->field);
			$this->simpleField = $ex;	
		}else{
			$this->simpleField = $this->field;
		}
		
		$this->viewFormat = $this->getProperty("viewType");
		
		$this->class = 'class="'.self::CTRL_NAMESPACE.'-table-access-share'.'"' ;		
	}

	public function generateRowCell( $context ){
		if($this->width != -1) {
			$model = $context->getModel();
			$pkey = $context->getPKey();
			if( AccessManager::checkAccessToModifyAccess($model, $pkey, null, true) )
				$content = "<a class=\"access_share ico_lock\" href=\"{$pkey}\" rel=\"{$model}\" ></a>" ;
			else $content = "" ;
			return  "<td {$this->class} >$content</td>";
		}
		
		return "";
	}

}

?>